package router

import (
	"github.com/gin-gonic/gin"
	"news/api"
	"news/controller"
	"news/middleware"
)

// InitRouters 初始化路由
func InitRouters() *gin.Engine {
	Router := gin.Default()

	v1 := Router.Group("v1").Use(middleware.Check())
	{
		v1.GET("/art/article_del", api.ArticleDel).Use(middleware.Check()) //文章删除
		v1.POST("/user/check", api.Check)                                  //检测权限
	}
	//不需要验证
	class := Router.Group("v1")
	class.POST("/user/login", api.Login)     //用户登录接口
	class.GET("/art/list", api.List)         //文章列表接口
	class.GET("/art/category", api.CateGory) //文章栏目接口
	class.GET("/art/detail", api.Detail)     //文章详情接口
	Router.GET("/info", api.Info)            //网站数据统计接口

	Router.GET("/", controller.ArtList)         //首页模板加载
	Router.GET("/detail", controller.ArtDetail) //详情页面加载
	Router.GET("/login", controller.Login)      //用户登录界面加载

	return Router
}
